package com.tianma315.admin.produce.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.produce.VO.ScFeedingVO;
import com.tianma315.admin.produce.domain.ScDisinfectDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.produce.dao.ScFeedingDao;
import com.tianma315.admin.produce.domain.ScFeedingDO;
import com.tianma315.admin.produce.service.ScFeedingService;

import java.util.List;

/**
 * 
 * <pre>
 * 投料(生产任务)
 * </pre>
 * <small> 2019-05-30 09:53:18 | Aron</small>
 */
@Service
public class ScFeedingServiceImpl extends CoreServiceImpl<ScFeedingDao, ScFeedingDO> implements ScFeedingService {


    @Autowired
    private ScFeedingDao scFeedingDao;

    @Override
    public Page<ScFeedingVO> getScFeedingVOPage(Integer pageNumber, Integer pageSize, ScFeedingDO scFeeding) {
        Page<ScFeedingVO> page = new Page<>(pageNumber,pageSize);
        page.setRecords(scFeedingDao.getScFeedingVOPage(scFeeding.getProduceTaskId()));
        return page;
    }

    @Override
    public Boolean addScFeedingDO(ScFeedingDO scFeeding) {
        scFeeding.setState(0);
        return insert(scFeeding);
    }

    @Override
    public Boolean deleteScFeedingDO(Integer id) {
        ScFeedingDO scFeedingDO = new ScFeedingDO();
        scFeedingDO.setState(1);
        scFeedingDO.setFeedingId(id);
        return updateById(scFeedingDO);
    }

    @Override
    public List<ScFeedingDO> getScFeedingDO(Integer produceTaskId) {
        Wrapper<ScFeedingDO> wrapper = new EntityWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("produce_task_id",produceTaskId);
        List<ScFeedingDO> scFeedingDOList = selectList(wrapper);
        return scFeedingDOList;
    }
}
